home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / cuj0593.zip / 1105100A < prev    next >
Text File  |  1993-05-16  |  671b  |  34 lines

  1. /* copy5.c */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. main(int argc, char *argv[])
  7. {
  8.     if (argc == 3)
  9.     {
  10.         char buf[BUFSIZ];
  11.         FILE *inf, *outf;
  12.  
  13.         if ((inf = fopen(argv[1],"rb")) == NULL)
  14.             return EXIT_FAILURE;
  15.  
  16.         if ((outf = fopen(argv[2],"wb")) == NULL)
  17.             return EXIT_FAILURE;
  18.  
  19.         while (!feof(inf))
  20.         {
  21.             int nitems = fread(buf,1,BUFSIZ,inf);
  22.             if (fwrite(buf,1,nitems,outf) != nitems)
  23.                 return EXIT_FAILURE;
  24.         }
  25.  
  26.         fclose(inf);
  27.         fclose(outf);
  28.         return EXIT_SUCCESS;
  29.     }
  30.     else
  31.         return EXIT_FAILURE;
  32. }
  33.  
  34.